Don't leak on non-uniq blank names. Don't read past beginning of string
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 18 Mar 2005 19:20:31 +0000 (19:20 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 18 Mar 2005 19:20:31 +0000 (19:20 +0000)
on blank names after blank whacking applied.

gpsbabel/mkshort.c

index 48ab322d87ecb6fc9c3405bc8409035f2e097e9b..1efcb7812b3c2bb0f1af8c0a9ad349d05390a66a 100644 (file)
@@ -387,7 +387,7 @@ mkshort(void *h, const char *istring)
         * Walk in the Woods 2.
         */
        np = ostring + strlen(ostring);
-       while (isdigit(*(np-1) )) {
+       while (*np && isdigit(*(np-1) )) {
                np--;
        }
        if (np) {
@@ -407,6 +407,7 @@ mkshort(void *h, const char *istring)
         * let the must_uniq code handle it.
         */
        if (ostring[0] == '\0') {
+               xfree(ostring);
                ostring = xstrdup("WPT");
        }